package game.gui;

import engine.game.Manager;
import engine.graphics.FontManager;
import engine.gui.GameButton;
import engine.gui.Panel;
import engine.gui.ParentObject;
import engine.gui.events.EventMethod;

public class ContextMenu extends Panel{

	private static final long serialVersionUID = 1L;
	
	public ContextMenu(Manager m, ParentObject parent, int w, int h) {
		super(m, parent, w, h) ;
	}
	public ContextMenu(Manager m, int x, int y, int w, int h) {
		super(m, x, y, w, h) ;
	}
	
	public void addNewButton(String caption, EventMethod event){
		int i = this.getAllChildren().size();
		GameButton tmp = new GameButton(this.getManager(), (int) this.getMinX(), 
					(int)this.getMaxY() - ((i-1)*20), this.getObjectWidth(), 20); 
		tmp.changeCaption(caption);
		tmp.getLabel().setFontName(FontManager.S_FONT_13);
		int px = (tmp.getObjectWidth() - (caption.length()*FontManager.getFontByName(tmp.getLabel().getFontName()).getFont().getSize() / 3 * 2)) / 2 ; 
		tmp.labelPadding(px, -7);
		tmp.onClick(event);
		this.addNewChild(caption, tmp);	
	}

}
